package br.usp.ime.origami.solver;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;

public class Part {

    private int length;

    private Orientation orientation = Orientation.SAME;

    public Part(int length) {
        this.length = length;
    }

    public JButton getButtonFor(final Component canvas) {
        JButton button = new JButton("len " + length);
        button.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                orientation = orientation.inverse();
                canvas.repaint();
            }
        });
        return button;
    }

    public int getLength() {
        return length;
    }

    public Orientation getOrientation() {
        return this.orientation;
    }

}
